<template>
  <TCollapse :title="this.newPrjDetail.manageMode === '05'?'子项目列表':'单项工程列表'">
    <accButton
      :prj-id="prjId"
      :select-list="selectList"
      :btn-list="btnOptions"
      @getTable="getTable"
      @clearList="handleClearList"
    />
    <accTable :table-header="tableHeader" :table-data="tableData" @changeCheck="handleCheck" @changeData="handleData" />
    <pagination
      :is-popper-body="false"
      :total="total"
      :page.sync="params.pageNum"
      :limit.sync="params.pageSize"
      @pagination="getTable"
    />
  </TCollapse>
</template>
<script>
import accButton from '@/views/acceptance/components/accButton.vue'
import { Mixins } from '@/views/acceptance/components/minix'
import accTable from '../table.vue'
import { tableMinix } from '@/views/acceptance/components/tableMinix'
export default {
  name: 'Plan',
  components: { accButton, accTable },
  mixins: [Mixins, tableMinix],
  data() {
    return {
      btnList_: ['materialBinding', 'materialService', 'serviceEdit', 'entering', 'apply', 'check', 'siteList'],
      siteList: []
    }
  },
  computed: {
    isReplace() {
      return this.newPrjDetail.buildModes === '07'
    },
    // 整体项目 智联 无实施
    getShowOne() {
      return this.newPrjDetail.manageMode === '03' && this.newPrjDetail.isNewBusiness === '1' && this.newPrjDetail.ifNewStartupProcess === '1'
    },
    // 维护改造
    getShowCopyOne(){
      return this.newPrjDetail.isNewBusiness === '0'&&this.newPrjDetail.businessMajor==='04'
    },
    // 服务成本 设备录入
    noSbLr() {
      return this.tableData[0]?.prjType === 'W' && this.newPrjDetail.buildModes === '26'
    },
    // 服务成本-购买服务
    noGouMaiSbLr() {
      return this.tableData[0]?.prjType === 'W' && this.newPrjDetail.buildModes === '25'
    },
    // 代建服务-代建类
    noAgent() {
      return this.tableData[0]?.prjType === 'Q' && this.newPrjDetail.buildModes === '07'
    },
    // 资源录入的按钮
    resourceEntryBtn() {
      // 1.代建服务-代建类 ||服务成本-设备录入 不涉及乙供物资明细配置
      const list = ['materialBinding', 'materialService', 'serviceEdit', 'entering', 'siteList', 'panorama']
      if (this.noAgent) {
        return list.filter(item => !(['serviceEdit'].includes(item)))
      } else if (this.noSbLr) {
        return list.filter(item => !(['serviceEdit', 'materialBinding', 'materialService'].includes(item)))
      } else {
        return list
      }
    },
    // 资源确认按钮
    resourceConfirmBtn() {
      // 1.代建服务-代建类 ||服务成本-设备录入 不涉及乙供物资明细配置
      const lists = ['serviceShow', 'materialAffirm', 'panorama']
      const isRight = this.noAgent || this.noSbLr
      return isRight ? lists.filter(item => item !== 'serviceShow') : lists
    },
    // 内部验收按钮
    acceptanceBtn() {
      const data1 = ['materialBinding', 'materialService', 'serviceEdit', 'panorama'] // 无交维 只有服务成本-购买显示serviceEdit
      const data2 = ['materialShow', 'serviceShow', 'panorama'] // 有交维
      const isJiaowei = this.newPrjDetail.isMaintain === '0' // 是否交维 1是 0否
      const fuwuchengben = this.noSbLr ? ['panorama'] : data2
      // 购买服务才会显示乙供物资明细配置
      return isJiaowei ? data1.filter(item => !this.noGouMaiSbLr ? item !== 'serviceEdit' : true) : fuwuchengben
    },
    refineLuRu(){
      return (this.getShowOne||this.getShowCopyOne) && this.newWorkDetail.bizObject.bizState === 'F4'
    },
    refineQueRen(){
      return (this.getShowOne||this.getShowCopyOne) && this.newWorkDetail.bizObject.bizState === 'F5'
    },
    refineYanShow(){
      return (this.getShowOne||this.getShowCopyOne)&& this.newWorkDetail.bizObject.bizState === 'F1'
    },
    refineGuanBi(){
      return (this.getShowOne||this.getShowCopyOne) && this.newWorkDetail.bizObject.bizState === 'F7'
    },
    refineGuanBiTwo(){
      return ['serviceShow', 'panorama'].filter(item => this.isReplace || this.noSbLr ? item !== 'serviceShow' : true)
    },
    btnList() {
      const { bizState } = this.newWorkDetail.bizObject
      // 智联项目 整体项目 无实施
      if (this.refineLuRu){
        // 资源录入
        return this.commonButtonShow(this.resourceEntryBtn)
      } else if (this.refineQueRen) {
        // 资源确认
        return this.resourceConfirmBtn
      } else if (this.refineYanShow) {
        // 内部验收
        return this.newPrjDetail.manageMode === '05'?['checkValuation']:this.acceptanceBtn
      } else if (this.refineGuanBi) {
        return this.refineGuanBiTwo
      } else {
        // 通信
        return this.newPrjDetail.manageMode === '05'?['checkValuation']:this.btnList_
      }
    }
  },
}
</script>

<style scoped lang='scss'></style>
